package com.chaosj.platform.wx.eventhandler;

import com.chaosj.memory.CmdParserHandler;
import com.github.sd4324530.fastweixin.handle.MessageHandle;
import com.github.sd4324530.fastweixin.message.BaseMsg;
import com.github.sd4324530.fastweixin.message.TextMsg;
import com.github.sd4324530.fastweixin.message.req.BaseReqMsg;
import com.github.sd4324530.fastweixin.message.req.ReqType;
import com.github.sd4324530.fastweixin.message.req.TextReqMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @className: ScrapeArticle
 * @description:
 * @author: caoyangjie
 * @date: 2021/12/28
 **/
//@Service
public class ScrapeArticleHandler implements MessageHandle<TextReqMsg> {
//    @Autowired
    CmdParserHandler handler;

    @Override
    public BaseMsg handle(TextReqMsg message) {
        StringBuffer buffer = new StringBuffer();
        handler.execute(new String[]{"wx", message.getContent()}, buffer);
        return new TextMsg("文章爬取成功!");
    }

    @Override
    public boolean beforeHandle(TextReqMsg message) {
        return message.getMsgType().equalsIgnoreCase(ReqType.TEXT);
    }
}
